<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<link href="../../js/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
		<link rel="stylesheet" type="text/css" href="footer.css" />
		<link rel="stylesheet" href="../../css/lystyle.css" />
		<link rel="stylesheet" href="../../css/backstage.css" />
		<style type="text/css">
			/*修改底部字体颜色*/
			
			.foot:nth-child(2) {
				color: #e83023;
			}
			
			.ly-line {
				margin: 5px 0.69444rem;
				height: 1px;
				background: #DEDEDE;
			}
			
			a.ly-borderp:hover {
				color: #fff;
			}
			/*修改底部字体颜色*/
			
			.foot:nth-child(2) {
				color: #e83023;
			}
			
			.ly-line {
				margin: 5px 0.69444rem;
				height: 1px;
				background: #DEDEDE;
			}
			
			.ly-info li {
				box-shadow: 0.069444rem 0.069444rem 0.069444rem #b3b3b3;
				margin-bottom: 0.277777rem;
				border-top: 0.013888rem solid #f8f8f8;
			}
			
			.ly-info {
				border: 0;
			}
			
			.ly-font16:hover {
				color: #E8323E;
			}
			.red_border{
				border-bottom: 1px solid red;
			}
		</style>
		<script src="../../js/flexible.min.js" type="text/javascript" charset="utf-8"></script>

		<script>
			function redborder1(){
					$("#fie").removeClass("red_border");
					$("#willFie").addClass("red_border");
				
				}
				function redborder(){
					$("#willFie").removeClass("red_border");
					$("#fie").addClass("red_border");
					
				}
		</script>
	</head>

	<body>
		<div id="wrap">
			<div id="main">
				<div id="header">
					<a id="headImg" href="javascript:history.go(-1)"><img class="headImg" src="../../images/12.png" /></a>
					<p id="headTitle">我的评价</p>
				</div>
				<div id="ly-nav" class="row">
					<div id="orderAll" class="ly-nav ly-nav-active col-xs-6 col-sm-6">
						<span id="willFie" style="padding-bottom: 0.2rem;" class="ly-font16 red_border" onclick="redborder1()">待评价</span>
					</div>
					<div id="orderToPay" class="ly-nav col-xs-6 col-sm-6">
						<span id="fie" style="padding-bottom: 0.2rem;" class="ly-font16" onclick="redborder()">已评价</span>
					</div>
				</div>
				<!--内容-->
				<div id="content">
					<!--全部-->
					<ul class="ly-info">
						<!---->

					</ul>
				</div>
			</div>
		</div>

	</body>
	<script src="../../js/jquery-2.2.3.min.js"></script>
	<script src="../../../common/js/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
	<script src="../../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
	<script>
		var tokenReztApp = $.cookie("tokenReztApp");
		if(!tokenReztApp) {
			window.location.href = "../login/login/login.html";
		}
		$(function() {
			currentyf();
		});

		//用户信息
		var user, role, goodsId;
		//获取当前会员信息
		function currentyf() {
			$.ajax({
				cache: false,
				type: "GET",
				url: "http://47.104.13.109/member-service/auth/current?token=" + tokenReztApp,
				dataType: "JSON",
				async: false,
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					$.removeCookie('tokenReztApp', {
						expires: 7,
						path: '/'
					});
					$.removeCookie("tokenRh", {
						expires: 7,
						path: '/'
					});
					$.removeCookie('memberId', {
						expires: 7,
						path: '/'
					});
					$.removeCookie('roleId', {
						expires: 7,
						path: '/'
					});
					window.location.href = "../login/login/login.html";
				},
				success: function(data) {
					user = data.loginName;
					role = data.roleList[0].id; //角色
					goodsId = data.id;

				}
			});
		}
		$(document).ready(function() {
			$(".ly-nav").click(function() {
				$('.ly-nav').removeClass('ly-nav-active');
				$(this).addClass('ly-nav-active');
				
			});
			
			function willFievalute() {
				//获取订单列表
				$.ajax({
					type: "get",
					url: "http://47.104.13.109/mall-service/order/list",
					async: true,
					data: {
						memberId: $.cookie("memberId"),
						pageNum: '1',
						pageSize: '666'
					},
					success: function(res2) {
						//						console.log(res2)
						var str = '';
						$.each(res2.list, function(idx2, item2) {
							//判断完成订单并未做评价
							//							console.log(item2.siId);
							//
							//查询商家评论列表
							$.ajax({
								type: "get",
								url: "http://47.104.13.109/mall-service/assess/list",
								async: true,
								data: {
									shopId: item2.siId,
									pageNum: 1,
									pageSize: 100,
								},
								
								
								success: function(res4) {
									console.log(res4.list.length);
									if(res4.list.length == 0 && item2.orderStatus == 1) {
										//获取商家信息
										$.ajax({
											type: "get",
											url: "http://47.104.13.109/mall-service/shop/search",
											async: true,
											data: {
												shopId: item2.siId
											},
											success: function(res3) {
												//												console.log(res3)
												str += '<li><div class="ly_storeinfo ly-color7D"><p><img src="../../images/personage/store.png"/><span style="font-size: 14px;">商店名称：</span><span>' + res3.shopName + '</span></p><p><img src="../../images/personage/category.png"/><span style="font-size: 14px;">类型：</span><span>' + res3.catName2 + '</span></p><p><img src="../../images/personage/order.png"/><span style="font-size: 14px;">订单编号：</span><span>' + item2.orderSn + '</span></p><p><img src="../../images/personage/address.png"/><span style="font-size: 14px;">商家地址：</span><span>' + res3.shopAdd + '</span></p></div><div class="ly-line"></div><div class="ly_shop ly-color7D"><p><span style="font-size: 14px;">消费仁和币金额：</span><span>' + item2.orderCoinrh + '</span></p><p><span style="font-size: 14px;">消费现金：</span><span>' + item2.orderNum + '</span></p><div style="text-align: right;padding:0rem 0.33rem 0.33rem 0;"><a class="ly-borderp" href="person_assess.html?memberName=' + item2.memberName + '&memberNumber=' + item2.memberName + '&goodsId=' + item2.orderSn + '&shopId=' + res3.shopId + '&shopName=' + res3.shopName + '&shopNumber=' + res3.shopId + '&shopPic=' + res3.shopPic + '" style="padding: 0.08rem 0.33rem;margin-right: 0px;">评价</a></div></li>';
												$('.ly-info').html(str);
											}
										});
									}
								}
							});

						});

					}
				});

			}
			willFievalute()

			$("#willFie").click(function() {
				$('.ly-info').html('');
				willFievalute()
				
			})
			$("#fie").click(function() {
				fieBol = false;
				$('.ly-info').html('');
				
				
				
				//获取评价列表
				$.ajax({
					type: "get",
					url: "http://47.104.13.109/mall-service/assess/list2",
					async: true,
					data: {
						memberId: $.cookie("memberId"),
						pageNum: '1',
						pageSize: '666'
					},
					success: function(res1) {
						//							console.log(res1)

						//获取订单列表
						$.ajax({
							type: "get",
							url: "http://47.104.13.109/mall-service/order/list",
							async: true,
							data: {
								memberId: $.cookie("memberId"),
								pageNum: '1',
								pageSize: '666'
							},
							success: function(res2) {
								var str = ''
								$.each(res1.list, function(idx1, item1) {
									console.log(item1)
									$.each(res2.list, function(idx2, item2) {
										if(item1.shopId == item2.siId && item2.orderStatus == 1) {
											//获取商家信息
											$.ajax({
												type: "get",
												url: "http://47.104.13.109/mall-service/shop/search",
												async: true,
												data: {
													shopId: item2.siId
												},
												success: function(res3) {
													str += '<li><div class="ly_storeinfo ly-color7D"><p><img src="../../images/personage/store.png"/><span style="font-size: 14px;">商店名称：</span><span>' + res3.shopName + '</span></p><p><img src="../../images/personage/category.png"/><span style="font-size: 14px;">类型：</span><span>' + res3.catName2 + '</span></p><p><img src="../../images/personage/order.png"/><span style="font-size: 14px;">订单编号：</span><span>' + item2.orderSn + '</span></p><p><img src="../../images/personage/address.png"/><span style="font-size: 14px;">商家地址：</span><span>' + res3.shopAdd + '</span></p></div><div class="ly-line"></div><div class="ly_shop ly-color7D" style="padding-right:1.163884rem;"><p><span style="font-size: 14px;">消费仁和币金额：</span><span>' + item2.orderCoinrh + '</span></p><p><span style="font-size: 14px;">消费现金：</span><span>' + item2.orderNum + '</span></p><p style="line-height:20px;font-size:14px;padding-bottom:10px;">评价内容：' + item1.assessContent + '</p></li>';
													$('.ly-info').html(str);
												}
											})
										}
									});
								});

							}
						});

					}
				});

			})

		});
	</script>

</html>